home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / cug233 / oki.c < prev    next >
Text File  |  1987-06-30  |  3KB  |  98 lines

  1. /* ibm printer set-up program */
  2. #include "stdio.h"
  3. #define SI '\17'    /* 17 cpi */
  4. #define DC2 '\22'    /* 10 cpi */
  5. #define ESC '\33'    /* escape */
  6. #define C0 '\60'    /* esc 0 = 8 lpi */
  7. #define C1 '\61'    /* esc 1 = 7/72 lpi */
  8. #define C2 '\62'    /* esc 2 = 6 lpi */
  9. #define CE '\105'    /* esc e = emphasized */
  10. #define CF '\106'    /* esc f cancels */
  11. #define CG '\107'    /* esc g = enhanced */
  12. #define CH '\110'    /* esc h cancels */
  13. #define CW '\127'       /* esc w double width */
  14. #define CX '\130'    /* esc x 1/esc x 0 start/stop corresp */
  15.  
  16. extern FILE *fopen();
  17. extern char *fgets();
  18. extern int fclose(), fputc();
  19. FILE *prn;
  20. int i, j, buflen=15;
  21. char buf[15], *bufptr;
  22. main()
  23. {
  24.     for(i=1;i<=24;++i)
  25.         printf("\n");  /* clear screen */
  26.     printf("Okidata pc setup program\n\n");
  27.     printf("Enter number(s) of options and then press ENTER\n\n");
  28.     printf("1...10 CPI (default)\n2...17 CPI\n");
  29.     printf("3...6 LPI (default)\n4...8 LPI\n");
  30.     printf("5...7/72 LPI\n6...Emphasized print\n");
  31.     printf("7...Enhanced print\n8...Correspondence print\n");
  32.     printf("9...Double wide\n0...reset all defaults\n\n");
  33.     printf("Choice ==>");
  34.     bufptr = fgets(buf,buflen,stdin);
  35.     prn = fopen("PRN:","w");
  36.     if(prn == NULL) abort("Can\'t open the printer");
  37.     while(*bufptr != EOS){
  38. j = fputc(*bufptr,stderr);
  39. j = fputc('\n',stderr);
  40.         switch(*bufptr){
  41.             case '1':
  42.                 j = fputc(DC2,prn);
  43.                 break;
  44.             case '2':
  45.                 j = fputc(SI,prn);
  46.                 break;
  47.             case '3':
  48.                 j = fputc(C2,prn);
  49.                 break;
  50.             case '4':
  51.                 j = fputc(ESC,prn);
  52.                 j = fputc(C0,prn);
  53.                 break;
  54.             case '5':
  55.                 j = fputc(ESC,prn);
  56.                 j = fputc(C1,prn);
  57.                 break;
  58.             case '6':
  59.                 j = fputc(ESC,prn);
  60.                 j = fputc(CE,prn);
  61.                 break;
  62.             case '7':
  63.                 j = fputc(ESC,prn);
  64.                 j = fputc(CG,prn);
  65.                 break;
  66.             case '8':
  67.                 j = fputc(ESC,prn);
  68.                 j = fputc(CX,prn);
  69.                 j = fputc(C0,prn);
  70.                 break;
  71.             case '9':
  72.  
  73.                 j = fputc(ESC,prn);
  74.                 j = fputc(CW,prn);
  75.                 j = fputc(C1,prn);
  76.                 break;
  77.  
  78.             case '0':
  79.                 j = fputc(DC2,prn);
  80.                 j = fputc(ESC,prn);
  81.                 j = fputc(C2,prn);
  82.                 j = fputc(ESC,prn);
  83.                 j = fputc(CX,prn);
  84.                 j = fputc(C0,prn);
  85.                 j = fputc(ESC,prn);
  86.                 j = fputc(CF,prn);
  87.                 j = fputc(ESC,prn);
  88.                 j = fputc(CH,prn);
  89.                 j = fputc(ESC,prn);
  90.                 j = fputc(CW,prn);
  91.                 j = fputc(C0,prn);
  92.                 break;
  93.         }
  94.         ++bufptr;
  95.     }
  96.     i = close(prn);
  97. }
  98.